<?php
/**
 * Create by Phpstorm
 * User: Peco
 * Date: 2019/12/17
 * Time: 22:15
 */

namespace App\Repositories;

use App\Models\Settings;

class SettingRepository
{
    /**
     * @var Settings 注入的 model
     */
    protected $settings;

    /**
     * SettingRepository constructor.
     * @param Settings $settings
     */
    public function __construct(Settings $settings)
    {
        $this->settings = $settings;
    }

    /**
     * 保存配置
     * @param $key
     * @param $value
     * @return mixed
     */
    public function saveSettingRepository($key, $value){
        if($this->settings->updateOrCreate(['key'=>$key], ['value'=>$value])){
            return $this->settings;
        }

        return false;
    }
}
